/**
 * 
 */
package com.m7012e.a_remote.communication.positioning;

import com.leoj.utils.Couple;

/**
 * @author leoj
 *
 */
public class SimplePosition extends Position {
	/**
	 * 
	 */
	private static final long serialVersionUID = -7411434817729867200L;
	private Couple<Integer, Integer> _pos;
	/**
	 * 
	 */
	public SimplePosition(int x, int y) {
		_pos = new Couple<Integer, Integer>(x, y);
	}
	public SimplePosition(){
		this((int)(Math.random()*100),(int)(Math.random()*100));
	}
	
	public int getX(){ return _pos.getFirst(); }
	public int getY(){ return _pos.getSecond(); }
	/* (non-Javadoc)
	 * @see java.lang.Comparable#compareTo(java.lang.Object)
	 */
	@Override
	public int compareTo(Position arg0) {
		if(arg0 instanceof SimplePosition){
			SimplePosition otherPosition = (SimplePosition) arg0;
			return (int) Math.sqrt(
					Math.pow((otherPosition.getX() - this.getX()),2)
					+ Math.pow((otherPosition.getY() - this.getY()), 2));
		}else{
			throw new RuntimeException("uncompatible position type ! -> "+arg0.getClass().toString());
		}
	}
	
	/* (non-Javadoc)
	 * @see java.lang.Object#toString()
	 */
	@Override
	public String toString() {
		return "SimplePosition:("+getX()+";"+getY()+")";
	}
}
